<!--食(物)品用量统计表-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="renderer" content="webkit">
<!-- TopJUI框架样式 -->
<link type="text/css" href="../../general/topjui/themes/default/topjui.core.min.css" rel="stylesheet">
<link type="text/css" href="../../general/topjui/themes/default/topjui.blue.css" rel="stylesheet" id="dynamicTheme" />
<!-- FontAwesome字体图标 -->
<link type="text/css" href="../../general/static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<!-- layui框架样式 -->
<link type="text/css" href="../../general/static/plugins/layui/css/layui.css" 	rel="stylesheet" />
<!-- jQuery相关引用 -->
<script type="text/javascript" src="../../general/static/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../general/static/plugins/jquery/jquery.cookie.js"></script>
<!-- TopJUI框架配置 -->
<script type="text/javascript" src="../../general/static/public/js/topjui.config.js"></script>
<!-- TopJUI框架核心-->
<script type="text/javascript" src="../../general/topjui/js/topjui.core.min1.js"></script>
<!-- TopJUI中文支持 -->
<script type="text/javascript" src="../../general/topjui/js/locale/topjui.lang.zh_CN.js"></script>
<!-- layui框架js -->
<script type="text/javascript" src="../../general/static/plugins/layui/layui.js" charset="utf-8"></script>

<!--自定义的样式与js-->
<link type="text/css" href="../a_allcommon/all.css" 	rel="stylesheet" />
<script type="text/javascript" src="../a_allcommon/all.js"></script>

</head>
<body>
	<div class="page_box">
		<!--title以及查询区div开始-->
		<div class="tjfx">
			<span style="padding: 10px;"></span>
			<div class="tjfx_title" style="width:5px;" id="t_t"></div>
			<div class="tjfx_query">
				<div class="lineL" style="width:80px;">项目名称：</div>
				<div class="lineR" style="width:150px;">
					<input type="text" name="q_tz_xiangmu_name" id="q_tz_xiangmu_name"
					       data-toggle="topjui-combobox"
					       data-options="prompt:'请选择项目名称',
					                  	 panelHeight:150,
					                   	 valueField:'zidian_value',
					                   	 textField:'zidian_value'">
				</div>
				<div class="lineL" style="width:60px;">类别：</div>
				<div class="lineR line2R">
					<input type="text" name="q_tz_zhonglei_name" id="q_tz_zhonglei_name"
					       data-toggle="topjui-combobox"
					       data-options="prompt:'请选择大类',
					                  	 panelHeight:350,
															 onSelect:function(node){
																	getA_ZhL_PZhList(node.id);
															 },
					                   	 valueField:'zhonglei_name',
					                   	 textField:'zhonglei_name'">
				</div>
				<div class="lineL"  style="width:90px;">食(物)品名：</div>
				<div class="lineR line2R"">
					<input type="text" name="q_tz_shipin_name" id="q_tz_shipin_name"
					       data-toggle="topjui-combobox"
					       data-options="prompt:'请选择食(物)品',
					                  	 panelHeight:350,
					                   	 valueField:'pinzhong_name',
					                   	 textField:'pinzhong_name'">
				</div>
				<div class="lineL" style="width:120px;">开始时间：</div>
				<div class="lineR line2R">
					<input type="text" name="q_start_time" data-toggle="topjui-datebox"
						data-options="id:'q_start_time',prompt:'请选择开始时间',width:225">
				</div>
				<div class="lineL" style="width:120px;">截止时间：</div>
				<div class="lineR line2R">
					<input type="text" name="q_end_time" data-toggle="topjui-datebox"
						data-options="id:'q_end_time',prompt:'请选择截止时间',width:225">
				</div>
				<span style="padding: 10px;"></span>
				<a href="javascript:doSubmit()" data-toggle="topjui-menubutton"
					 data-options="iconCls:'fa fa-search',btnCls:'topjui-btn-blue'">查询</a>
				<span style="padding: 5px;"></span>
				<a href="javascript:void(0)" data-toggle="topjui-menubutton"
					 data-options="btnCls:'topjui-btn-green'" onclick="exportExcel()">生成excel</a>
			</div>
		</div>
		<!--title以及查询区div结束-->
		
		<div class="grid_box">
			<!-- datagrid表格（fitColumns:true表示限制滚动条，fitColumns:false表示允许滚动条）-->
			<table data-toggle="topjui-datagrid" class="productDg1" 
			       data-options="id:'c_tjfxTable',fitColumns:false,remoteSort:false,pagination:false,rownumberWidth:39">
				<thead>
					<tr>
						<th data-options="field:'tz_xiangmu_name',title:'项目名称',sortable:true,width:250,align:'center'"></th>
						<th data-options="field:'riqi',title:'时间区间',sortable:true,width:250,align:'center'"></th>
						<th data-options="field:'tz_zhonglei_name',title:'种类',sortable:true,width:150,align:'center'"></th>
						<th data-options="field:'tz_shipin_name',title:'食(物)品名称',sortable:true,width:150,align:'center'"></th>
						<th data-options="field:'total_tz_shuliang',title:'总用量',sortable:true,width:150,align:'center'"></th>
						<th data-options="field:'tz_danwei',title:'单位',sortable:true,width:100,align:'center'"></th>
					</tr>
				</thead>
			</table>
		</div> <!--表格区div结束-->
		
	</div>
<script>
var HTMC_LIST=[]; //用于保存字典中项目名称下拉框的数据
var A_ZhL_LIST=[]; //用于保存种类下拉框的数据
var A_ZhL_PZh_LIST=[]; //用于保存不同种类下的食品名称下拉框的数据
$(function(){
	getA_ZDList("项目名称"); //取字典中项目名称集合
	getA_ZhLList(); //取种类名称集合
});
//根据键名取字典中的键值列表（用于填充项目名称、结款方式、验收人、这三个选择下拉）
function getA_ZDList(zidian_name){
	var formData={};
	formData.zidian_name=zidian_name;
	$.ajax({
		url:"/a_ZD/getA_ZDList",
		dataType:"JSON",
		type:"POST",
		data:formData,
		success:function(data){
			console.log("获取字典中键名为"+zidian_name+"的键值集合返回值data.rows==",data.rows);
			if(zidian_name=="项目名称"){
				HTMC_LIST=data.rows;
				$('#q_tz_xiangmu_name').iCombobox('loadData',HTMC_LIST);
			}
		}
	});
}
//取种类列表（用于填充种类下拉）
function getA_ZhLList(){
	var formData={};
	formData.pageIndex=1;
	formData.pageSize=10000;
	$.ajax({
		url:"/a_ZhL/getA_ZhLList",
		dataType:"JSON",
		type:"POST",
		data:formData,
		success:function(data){
			console.log("获取种类集合返回值data.rows==",data.rows);
			A_ZhL_LIST=data.rows; //将返回值赋值给全局变量
			debugger;
			//给种类查询条件框赋值
			$('#q_tz_zhonglei_name').iCombobox('loadData',A_ZhL_LIST);
		}
	});
}
//根据种类id取食品名称列表（用于填充食品名称下拉）（联动触发）
function getA_ZhL_PZhList(zhonglei_id){
	var formData={};
	formData.zhonglei_id=zhonglei_id;
	formData.pageIndex=1;
	formData.pageSize=10000;
	$.ajax({
		url:"/a_ZhL_PZh/getA_ZhL_PZhList",
		dataType:"JSON",
		type:"POST",
		data:formData,
		success:function(data){
			console.log("获取指定种类下的食物品集合返回值data.rows==",data.rows);
			A_ZhL_PZh_LIST=data.rows; //将返回值赋值给全局变量
			$('#q_tz_shipin_name').iCombobox('loadData',A_ZhL_PZh_LIST);
			debugger;
		}
	});
}

/*************************************表格相关方法****************************************/
/********使用ajax返回的数据的方式加载表格（如下2个主要方法）*******/
//表格主查询（包含条件查询）
function doSubmit(){
	$('#t_t').text(''); //标题区先初始化
	var formData={};
	//1：取查询参数 
	var q_tz_xiangmu_name=$('#q_tz_xiangmu_name').iCombobox('getValue'); //项目名称
	if(q_tz_xiangmu_name==""){
		$.iMessager.alert('警告', '请选择项目！', 'messager-warning');
		return;
	}else{
		formData.tz_xiangmu_name=q_tz_xiangmu_name;
	}
	
	var q_tz_zhonglei_name=$('#q_tz_zhonglei_name').iCombobox('getValue'); //大类别
	if(q_tz_zhonglei_name!=''){
		formData.tz_zhonglei_name=q_tz_zhonglei_name;
	}
	var q_tz_shipin_name=$('#q_tz_shipin_name').iCombobox('getValue'); //食（物）品名
	if(q_tz_shipin_name!=''){
		formData.tz_shipin_name=q_tz_shipin_name;
	}
	
	var q_start_time=$('#q_start_time').iDatebox('getValue'); //开始时间
	var q_end_time=$('#q_end_time').iDatebox('getValue'); //截止时间
	if(q_start_time=="" || q_end_time==""){
		$.iMessager.alert('警告', '请选择开始时间与截止时间！', 'messager-warning');
		return;
	}else{
		formData.start_time=q_start_time;
		formData.end_time=q_end_time;
	}
	
	//2：标题区赋值
	//$('#t_t').text('项目：'+q_tz_xiangmu_name+' '+q_start_time+'至'+q_end_time+'期间用量统计'); 
	debugger;
	//2：执行ajax查询请求
	$.ajax({
		url:"/c_Tjfx/getYltj",
		dataType:"JSON",
		type:"POST",
		data:formData,
		success:function(data){
			console.log(data.rows);
			debugger;
			//3：加载表格
			$("#c_tjfxTable").iDatagrid("loadData",data);//表格装载数据
		}
	});
}

</script>
</body>
</html>